import { inject, ref } from 'vue';

export const getMenuData = () => {
    const config = inject("config");
    const isShowArray = ref([])
    const menuObject = {}

    config.componentList.forEach(item => {
        if(!menuObject[item.type]) {
            menuObject[item.type] = []
            isShowArray.value.push(true)
        }
        menuObject[item.type].push({...item, isShow: true})
    })

    const clickNav = (index) => {
        isShowArray.value[index] = !isShowArray.value[index]
    }

    return {
        isShowArray,
        menuObject,
        clickNav
    }
}